package cn.bonoon.kernel.web.components;

import cn.bonoon.kernel.descriptors.UIPropertyAccessor;
import cn.bonoon.kernel.web.annotations.components.AsDatetimeBox;
import cn.bonoon.kernel.web.html.UIPropertyBuilder;
import cn.bonoon.kernel.web.html.form.ComponentPropertyParser;

public class DatetimeBoxComponent extends UIComponent{
	private final boolean showSeconds;
	public DatetimeBoxComponent(ComponentPropertyParser property, UIPropertyAccessor accessor, AsDatetimeBox asDatetimeBox) { 
		super("bupdatetimeinput", property, accessor);
		showSeconds = asDatetimeBox.showSeconds();
	}
	
	public DatetimeBoxComponent(ComponentPropertyParser property, UIPropertyAccessor accessor) { 
		super("bupdatetimeinput", property, accessor);
		showSeconds = true;
	}
	
	@Override
	protected void initComponentAttribute(StringBuilder script, UIPropertyBuilder builder) {
		script.append(",editable:false, withSecond:"); // showSeconds
		if(showSeconds){
			script.append("true");
		}else{
			script.append("false");
		}
	}
}
